// pages/shangpin_xq/shangpin_xq.js
const app = getApp()
//获得全局js变量
var util = require('../../utils/util.js');

var WxParse = require('../../wxParse/wxParse.js');
var replyHtml0 = ``;
Page({

    /**
     * 页面的初始数据
     */
    data: {
        imgurl:app.data.imgurl,
        list: [],
        indicatorDots: true,
        vertical: false,
        autoplay: false,
        interval: 2000,
        duration: 500,
        id:0,
        detail:[]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        this.setData({
            id: options.id
        });
        //获取商品详情
        this.shopdetail();
    },
    //获取商品详情
    shopdetail:function(){
        var that = this;
        var userid=this.data.userId;
        util.httpRrquest(app.data.rooturl + 'system/getShopDetailById', 'GET', { id: that.data.id})
        .then(function (response) {
            var data = response.data.data;
            that.setData({
                list: data.goodImgsSrc,
                detail: data
            })
            
            WxParse.wxParse('content', 'html', data.detail, that, 10);
            wx.setNavigationBarTitle({
                title: data.title
            })
        }, function (error) {
            console.log(error);
        });
    },
    callPhone:function(){
        var that=this;
        console.log(that.data.detail.contactPhone);
        wx.makePhoneCall({
            phoneNumber: that.data.detail.contactPhone,
            success: function () {
                console.log("拨打电话成功！")
            },
            fail: function () {
                console.log("拨打电话失败！")
            }
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function (res) {
        var shareinfo = app.setShareMessage();
        console.log(shareinfo);
        return {
            title: shareinfo.title,
            path: shareinfo.path,
            imageUrl: shareinfo.imageUrl,
            success: (res) => {
                wx.showToast({
                    title: "分享成功",
                    icon: 'loading'
                })
            }
        }
    }
})